import { createRouter, createWebHistory } from 'vue-router';

import {routes} from './staticRoutes'

const router = createRouter({
  history: createWebHistory(),
  routes
});

router.beforeEach((to,from,next)=>{
  const token = localStorage.getItem('token')
if(to.name !== 'Login' && !token) next({name:'Login'})
  else next()
})

export default router;
export { routes };